<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Admin_Priorityoptions extends Admin_Controller {
	public function __construct()
	{
		parent::__construct();
		$this->lang->load('priorityoption');
	}
	public function ajax_priorityoption_get(){
		$priorityoptionEntity =  new CI_Priority_option_entity();
		$priorityoption = $priorityoptionEntity->init('id',$_REQUEST['id']);
		echo json_encode($priorityoption);
	}
	public function ajax_priorityoption_list(){		
		$priorityoptionEntity =  new CI_Priority_option_entity();
		$priorityoptionList = $priorityoptionEntity->getPriorityOptionList();
		$data['priorityoptionList'] = $priorityoptionList;
		$this->load->view('admin/priorityoptions/index', $data);
	}
	public function ajax_priorityoption_save(){
		$result = array();
		$priorityoptionEntity =  new CI_Priority_option_entity();
		if($_REQUEST['priorityoption'] == null || $_REQUEST['priorityoption'] == ""){
			$result['result'] = false;
			$result['message'] = lang('escort_priorityoption_require');
		}else{
			$priorityoptionEntity->setPriority($_REQUEST['priorityoption']);
			$priorityoptionEntity->setPrice($_REQUEST['priorityprice']);
			$priorityoptionEntity->setPriorityPercentage($_REQUEST['priority_percentage']);
			$id = $priorityoptionEntity->save($priorityoptionEntity);
			$result['result'] = true;
			$result['message'] =lang('escort_priorityoption_save_success');
			$result['id'] =$id;
		}
		echo json_encode($result);
	}
	public function ajax_priorityoption_update(){
		$result = array();
		$priorityoptionEntity =  new CI_Priority_option_entity();
		if($_REQUEST['priorityoption'] == null || $_REQUEST['priorityoption'] == ""){
			$result['result'] = false;
			$result['message'] = lang('escort_priorityoption_require');
		}else{
			$priorityoptionEntity->setPriority($_REQUEST['priorityoption']);
			$priorityoptionEntity->setPrice($_REQUEST['priorityprice']);
			$priorityoptionEntity->setPriorityPercentage($_REQUEST['priority_percentage']);
			$priorityoptionEntity->setId($_REQUEST['id']);
			$priorityoptionEntity->update();
			$result['result'] = true;
			$result['message'] = lang('escort_priorityoption_save_success');
		}
		echo json_encode($result);
	}
	public function ajax_priorityoption_delete(){
		$result = array();
		$priorityoptionEntity =  new CI_Priority_option_entity();
		$priorityoptionEntity->delete($_REQUEST['id']);		
		echo json_encode($result);
	}
}
?>